Conversation
Changelog ReminderReminder to update the CHANGELOG.md for any of the modified packages in this PR.
|
packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperToken.sol
Show resolved
Hide resolved
packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperToken.sol
Show resolved
Hide resolved
| uint256 actualUpgradedAmount = amountAfter - amountBefore; | ||
| if (underlyingAmount != actualUpgradedAmount) revert SUPER_TOKEN_INFLATIONARY_DEFLATIONARY_NOT_SUPPORTED(); | ||
|
|
||
| if (address(_yieldBackend) != address(0)) { |
There was a problem hiding this comment.
move to _burn and _mint, so that selfBurn/selfMint could work too (for SETH).
There was a problem hiding this comment.
2 reasons against that:
- would need to add an
underlyingAmountargument (or duplicate the calculation) - in the selfBurn path we want to set a flag which avoids the withdrawn ETH to be wrapped to ETHx
| function withdrawSurplus(uint256 totalSupply) external { | ||
| // totalSupply is always 18 decimals while assetToken and aToken may not | ||
| (uint256 normalizedTotalSupply,) = ISuperToken(address(this)).toUnderlyingAmount(totalSupply); | ||
| // decrement by 1 in order to offset Aave's rounding up |
There was a problem hiding this comment.
find a reference to make it more precise.
| // totalSupply is always 18 decimals while assetToken and aToken may not | ||
| (uint256 normalizedTotalSupply,) = ISuperToken(address(this)).toUnderlyingAmount(totalSupply); | ||
| // decrement by 1 in order to offset Aave's rounding up | ||
| uint256 surplusAmount = A_TOKEN.balanceOf(address(this)) - normalizedTotalSupply - 1; |
There was a problem hiding this comment.
Take into account the stray balances of the underlying, forwhatever the reason it came about.
| function enableYieldBackend(IYieldBackend newYieldBackend) external onlyAdmin { | ||
| require(address(_yieldBackend) == address(0), "yield backend already set"); | ||
| _yieldBackend = newYieldBackend; | ||
| (bool success, ) = address(_yieldBackend).delegatecall( |
There was a problem hiding this comment.
consider an internal library boilerplate to hide the cruft away from the main super token logic.
| function depositMax() external { | ||
| uint256 amount = USING_WETH ? | ||
| address(this).balance : | ||
| ASSET_TOKEN.balanceOf(address(this)); |
There was a problem hiding this comment.
check scaledBalanceOf
/**
* @notice Returns the scaled balance of the user.
* @dev The scaled balance is the sum of all the updated stored balance divided by the reserve's liquidity index
* at the moment of the update
* @param user The user whose balance is calculated
* @return The scaled balance of the user
*/
function scaledBalanceOf(address user) external view returns (uint256);
Aave rounding issueWhen depositing X assetToken into an Aave pool, X aToken get minted. (18569 528966 means 18569.528966 USDC) Why does this happen?Aave uses continuously compounding interest for deposits. When an Aave asset pool is initialized, 1 share = 1 assetToken. Divided by 1e27 (named The user facing unit is not shares (which keep depegging further and further from the assetToken, but aTokens. When a user requests withdrawal of x assetTokens, Aave calculates the corresponding shares by dividing by r, rounding up (favoring the protocol). So, why do we already see some cases of the diff between aToken amount and assetAmount being 2? Economics of griefing attackSo, a user could grief SF by continuously downgrading/withdrawing choosing the amounts such that the (current) max rounding error of 2 wei per operation is lost. In order to cause a loss of 1 USDC, a griefer would need to spend min 150$ worth of tx fees with the gas price at 0.0005 gwei (current floor price of Base - assuming no blob cost). Note that the griefer would not get the 1 USDC, it would just withhold it from the SF protocol, at a high cost. Even if somebody would go and do that, this could happen in the following unrealistic, but theoretically possible worst case scenario:
In this scenario the griefer could withhold ~1.125 USDC from SF protocol by using all Base block space to accumulate rounding errors with repeated And even if this were to happen, it would still not be enough to offset the yield generated by Aave for SF with the current USDCx supply of ~400k. For asset tokens with 18 decimals (e.g. WETH) the amounts would be smaller by many orders of magnitude. |
packages/ethereum-contracts/contracts/interfaces/superfluid/IYieldBackend.sol
Outdated
Show resolved
Hide resolved
packages/ethereum-contracts/contracts/interfaces/superfluid/IYieldBackend.sol
Outdated
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
XKCD Comic RelifLink: https://xkcd.com/2125 |

No description provided.